package com.example.fishscavengerhunt;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.Spinner;
import android.widget.TextView;

public class Help extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_help);

		Spinner spinner = (Spinner) findViewById(R.id.helpSpinner);

		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
				this, R.array.help_array, android.R.layout.simple_spinner_item);

		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

		spinner.setAdapter(adapter);

		spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View view,
					int pos, long id) {
				TextView helpText = (TextView) findViewById(R.id.helpText);
				switch (pos) {
				case 0:
					helpText.setText("Click on New Game button.\n\n"
							+ "Slide through the cover flow to see the challenges.\n\n"
							+ "Choose a challenge to play.");
					break;
				case 1:
					helpText.setText("Click on Resume button.\n\n"
							+ "This will open the most recently played game.");
					break;
				case 2:
					helpText.setText("Click on Resume button.\n\n"
							+ "A progress bar across the top will show how far you have gone in the current challange.\n\n"
							+ "A checkmark will appear next to animals you have found and scanned.\n\n"
							+ "Click on the scan button to collect a new animal with a QR code.\n\n");
					break;
				case 3:
					helpText.setText("Click on Resume button.\n\n"
							+ "Click on Tank button.\n\n"
							+ "This will open your tank where you can see the fish you have collected.\n\n"
							+ "Click on a fish to see their description.");
					break;
				default:
					break;
				}
			}

			@Override
			public void onNothingSelected(AdapterView<?> arg0) {

			}

		});

		((ImageButton) findViewById(R.id.back))
				.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View v) {
						finish();
					}
				});
		((ImageButton) findViewById(R.id.home))
		.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent newIntent = new Intent(Help.this, Main.class);
            	Help.this.startActivity(newIntent);
            	finish();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.help, menu);
		return true;
	}

}
